package demo.actions;

import demo.services.IQueryService;
import framework.annotation.InchAutowired;
import framework.annotation.InchController;
import framework.annotation.InchRequestMapping;
import framework.annotation.InchRequestParam;
import framework.webmvc.component.InchModelAndView;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * controller class for show pages using pageAction.html
 */
@InchController
@InchRequestMapping("/")
public class PageAction {
    @InchAutowired IQueryService queryService;

    @InchRequestMapping("/page")
    public InchModelAndView query(@InchRequestParam("name") String name) {
        //transaction service used
        String result = queryService.query(name);
        //create model
        Map<String,Object> model = new ConcurrentHashMap<>();
        model.put("name", name);
        model.put("queryResult", result);
        //create model and view to show
        return new InchModelAndView("pageAction.html",model);
    }
}

